package com.lagou.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.annotation.MyAutoPage;
import com.lagou.mapper.ArticleMapper;
import com.lagou.pojo.Article;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:文章服务
 * @Author: zhoushiduo
 * @Date: 2020/12/13 19:55
 */

@Service("articleService")
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public PageInfo<Article> findByWherePage(Article article) {
        List<Article> articles = articleMapper.findByWhere(article);
        PageInfo<Article> articlePageInfo = new PageInfo<>(articles);
        return articlePageInfo;
    }

    @Override
    @MyAutoPage(false)
    public PageInfo<Article> findByWherePage(Article article, Integer pageNum) {
        PageHelper.startPage(pageNum, 3);
        List<Article> articles = articleMapper.selectList(null);
        PageInfo<Article> articlePageInfo = new PageInfo<>(articles);
        return articlePageInfo;
    }
}
